#ifndef MAINSCENEWIDGET_H
#define MAINSCENEWIDGET_H
#include "QD3D/QD3DWidget.h"
#include "ReconstructProcess.h"
#include "VisualizeProcess.h"
#include "CameraInterface.h"
#include "OctreeVisualizer.h"
#include "ModelVisualizer.h"
#include "OpenNIContextManager.h"


class MainSceneWidget : public QD3DWidget
{
	Q_OBJECT

public:
	MainSceneWidget (int argc, char *argv[], QWidget *parent = NULL);
	virtual ~MainSceneWidget ();

protected:
	virtual void initializeD3D ();

	virtual void paintD3D ();

	virtual void resizeD3D (int width, int height);

	virtual void cleanD3D ();

	void mousePressEvent (QMouseEvent * e);

	void mouseMoveEvent (QMouseEvent * e);

	void mouseReleaseEvent (QMouseEvent * e);

	void wheelEvent (QWheelEvent * e);

	void keyPressEvent (QKeyEvent * e);

	void keyReleaseEvent (QKeyEvent * e);

private:
 	OpenNIContextManager *_p_contextManager;
	ReconstructProcess _reconstructProcess;
	VisualizeProcess _visualizeProcess;
	OctreeVisualizer _octreeVisualizer;
	ModelVisualizer _modelVisualizer;
	Camera _camera;
	CameraInterface _cameraInterface;
	ID3D11BlendState *_pBlendState;
	bool _isPause;
	bool _isNext;
	bool _isTex;
	bool _isModelColor;
	bool _isShowNNSResult;
	bool _isCloudShow[9];
	bool _isModelShow;
	bool _isShowOctree;
	UINT _fps;
	clock_t _lastSecond;

	struct MatrixConstVars
	{
		glm::mat4 worldMatrix;
		glm::mat4 viewMatrix;
		glm::mat4 projectionMatrix;
	} _matrixConstVars;
	struct LightConstVars
	{
		glm::vec4 direction;
		glm::vec4 color;
	} _lightConstVars;
	bool _isMatrixBufUpdated;

	ID3D11Buffer *_p_matrixDxConstBuf;
	ID3D11Buffer *_p_lightDxConstBuf;

	void _parseCommandLineArgs (int argc, char *argv[]);

	void _updateConstBuf ();
	void captureScreen();


};

#endif // MAINSCENEWIDGET_H
